<?php $view->extend('::base.html.php') ?>
<?php $view['slots']->start('body') ?>
<?php 
if(isset($response)){
	echo $response;
}else{
	echo "hello world!";
}
?>
<br>

<form action="" method="post">
	<input type="text" name="var">
	<input type="submit" value="go!" onclick="submitAjax()">
</form>
<script>
function submitAjax()
{
	console.log("ajax sale");
	
	var AjaxRequest = $.ajax({
        type: "post",
        url: "<?php echo $view['router']->generate('ajax_response'); ?>",
        context: document.body,
        data: sarasa="hola",
        dataType: "json",
        success: function(){
        	console.log("ajax responde");
    	}
    });

	AjaxRequest.done(function() {
        console.log("ajax responde");
    });

}
</script>

<?php 
if(isset($success)){
?>
<script>
console.log("ajax responde");

</script>
<?php 
}
	
?>
<?php $view['slots']->stop() ?>